package com.yotta.operationdatascreencode.common.exception;

import com.yotta.operationdatascreencode.constants.CommonConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 业务异常处理类
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class BusinessException extends RuntimeException {
    //状态码
    private Integer code;

    //错误消息
    private String message;

    /**
     * 业务异常
     * @param message 错误信息
     */
    public BusinessException(String message) {
        this.code = CommonConstants.ERROR;
        this.message = message;
    }


    /**
     * 业务异常
     * @param code  状态码
     * @param message 消息
     */
    public BusinessException(Integer  code, String  message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 原始异常
     * @param throwable    原始异常对象
     */
    public BusinessException(Integer  code, String  message, Throwable throwable) {
        super(throwable);
        this.code = code;
        this.message = message;
    }
}
